package com.sz.app.oss.api.logistics.order;

import com.sz.app.oss.constants.MessagesCodes;
import com.sz.app.oss.constants.Permissions;
import com.sz.biz.app.web.BaseController;
import com.sz.common.base.dto.ResultDto;
import com.sz.common.base.utils.EntityUtils;
import com.sz.biz.logistics.ord.entity.OrdTrackingOriginal;
import com.sz.biz.logistics.ord.service.OrdTrackingOriginalService;
import com.sz.biz.logistics.ord.dto.OrdTrackingOriginalDto;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Package: com.sz.app.oss.api.logistics.order<br>
 * Function: 供应商传递的原始物流信息接口
 * Author: yanhong.xiao.<br>
 * Date: 2017-05-11 21:09:00.
 */
@RestController
@RequestMapping("/api/v1/order/originaltracking")
public class OrdTrackingOriginalController extends BaseController {
    @Autowired
    private OrdTrackingOriginalService trackingOriginalService;

    /**
     * 新增.
     */
    @ApiOperation(value = "新增", notes = "新增子订单的状态" + Permissions.BIZ_MGT_ORD_ORDER)
    @RequestMapping(value = "", method = {RequestMethod.POST})
    @RequiresPermissions(Permissions.BIZ_MGT_ORD_ORDER)
    public ResultDto save(@RequestBody @ApiParam(value = "要保存的数据", required = true) @Validated OrdTrackingOriginalDto dto) {
        OrdTrackingOriginal trackingOriginal = new OrdTrackingOriginal();
        dto.setId(null);//保存时忽略id
        EntityUtils.copyPropertiesIgnoreNull(dto, trackingOriginal);
        int id = trackingOriginalService.save(trackingOriginal);
        ResultDto result = getSaveSuccessDto(MessagesCodes.MODULE_ORDER_TRACKING);
        result.setData(id);
        return result;

    }
}
